package com.ys168.gam.download;

import java.net.URL;

/**
 * 
 * @author Jason Krebs
 * @since 2015年6月11日
 */
public class DownloadEvent {

    private URL url;
    private int index;
    private String message;
    private DownloadStatus status;
    private int successedCount;
    private int failedCount;

    public DownloadEvent(URL url, int index) {
        super();
        this.url = url;
        this.index = index;
        this.status = DownloadStatus.UN_STSARTED;
    }

    public DownloadEvent(URL url, int status, String message) {
        super();
        this.url = url;
        this.index = status;
        this.message = message;
    }

    public int getDownloadFinishedCount() {
        return successedCount + failedCount;
    }

    public int getFailedCount() {
        return failedCount;
    }

    public int getIndex() {
        return index;
    }

    public String getMessage() {
        return message;
    }

    public DownloadStatus getStatus() {
        return status;
    }

    public int getSuccessedCount() {
        return successedCount;
    }

    public URL getUrl() {
        return url;
    }

    public boolean isDownloadFailed() {
        return getStatus() == DownloadStatus.DOWNLOAD_FAILED;
    }

    public boolean isDownloadSuccessed() {
        return getStatus() == DownloadStatus.DOWNLOADED_SUCCESSED;
    }

    public void setFailedCount(int failedCount) {
        this.failedCount = failedCount;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setStatus(DownloadStatus status) {
        this.status = status;
    }

    public void setSuccessedCount(int successedCount) {
        this.successedCount = successedCount;
    }

}
